package com.example.administrator.zkdemo.application;

import android.app.Application;
import android.app.smdt.SmdtManager;
import android.content.Context;

import com.bumptech.glide.Glide;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;

/**
 * Created with Android Studio.
 * 描述: ${DESCRIPTION}
 * Date: 2018/11/19
 * Time: 16:01
 *
 * @author 晏琦云
 * @version ${VERSION}
 */
public class MainApplication extends Application {
    private static final String LOG_TAG = "SuperFacePlus";
    private static Context mContext;
    private RefWatcher mRefWatcher;
    private SmdtManager smdtManager;

    public static Context getContext() {
        return mContext;
    }

    public static RefWatcher getRefWatcher(Context paramContext) {
        return ((MainApplication) paramContext.getApplicationContext()).mRefWatcher;
    }

    private void initDB() {
        this.smdtManager = SmdtManager.create(this);
    }

    private void initLeakCanary() {
        if (LeakCanary.isInAnalyzerProcess(this))
            return;
        this.mRefWatcher = LeakCanary.install(this);
    }

    private boolean isLogEnable() {
        try {
            boolean bool = Boolean.valueOf(getPackageManager().getApplicationInfo(getPackageName(), 128).metaData.getBoolean("logEnable")).booleanValue();
            return bool == true;
        } catch (Exception localException) {
            localException.printStackTrace();
        }
        return false;
    }

    public SmdtManager getSmdtManager() {
        return this.smdtManager;
    }

    public void onCreate() {
        mContext = this;
        super.onCreate();
        initDB();
        initLeakCanary();
    }

    @Override
    public void onLowMemory() {
        super.onLowMemory();
        Glide.get(this).clearMemory();
    }
}
